// 不要修改原型链
import React from 'react';

function HOC(Component: any) {
  const proDidMount = Component.prototype.componentDidMount;
  Component.prototype.componentDidMount = function () {
    console.log('劫持生命周期1：componentDidMount');
    proDidMount.call(this);
  };
  return Component;
}

function HOC1(Component: any) {
  const proDidMount = Component.prototype.componentDidMount;
  Component.prototype.componentDidMount = function () {
    console.log('劫持生命周期2：componentDidMount');
    // proDidMount.call(this);
  };
  return Component;
}

class Demo extends React.Component {
  render() {
    return <div>demo</div>;
  }
}

export const Once = HOC(Demo);

export const Twice = HOC1(Once);
